package com.telit.firecommand.controller;

import com.telit.common.entity.DataReturn;
import com.telit.firecommand.service.FireAndEventHomeService;
import com.telit.firecommand.service.FireSituationService;
import com.telit.firecommand.strategy.context.FireResourceStrategyContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Auther amy
 * @Describe 资源控制层
 */
@RestController
@Api(tags = "首页接口控制层")
@RequestMapping("/resource")
public class ResourceController {

//    @Autowired
//    private UavUserService uavUserService;

    @Autowired
    private FireSituationService fireSituationService;

    @Autowired
    private FireResourceStrategyContext fireResourceStrategyContext;

    @Autowired
    private FireAndEventHomeService fireAndEventHomeService;

//    @GetMapping(value = "/total", produces = "application/json;charset=UTF-8")
//    @ApiOperation("表头-卫星/监控摄像/无人机/飞手/护林员")
//    public DataReturn resourceTotal(@RequestParam(value = "flag", required = false) String flag) {
//        return DataReturn.ok(uavUserService.resourceTotal(flag));
//    }

//    @GetMapping(value = "/fireTotal", produces = "application/json;charset=UTF-8")
//    @ApiOperation("首页-防火资源种类数量")
//    public DataReturn fireResourceTotal() {
//        return DataReturn.ok(fireSituationService.getFireTotal());
//    }

//    @GetMapping(value = "/resourceList", produces = "application/json;charset=UTF-8")
//    @ApiOperation("首页-防火资源列表查询")
//    public DataReturn selectResourceList(@RequestParam("type") String type,
//                                         @RequestParam(required = false) Map<String, Object> queryMap) {
//        if (!FireConstant.RESOURCE_LIST.contains(type)) {
//            throw new ForestBaseException(ResultCode.FORM_PARAMS_CHECK_ERROR.getCode(), "type 参数不符合");
//        }
//        return fireResourceStrategyContext.selectResourceList(type, queryMap);
//    }

    /**
     * 2022-07-04 旧版本无数据权限
     *
     * @return
     */
  /*  @GetMapping(value = "/fireAndEventCount",produces = "application/json;charset=UTF-8")
    @ApiOperation("首页-巡护巡航上报火情/事件总数")
    public DataReturn fireAndEventCount(){
        return DataReturn.ok(fireAndEventHomeService.selectFireAndEventCount());
    }
*/

    /**
     * 2022-07-04 新版本有数据权限
     *
     * @return
     */
    @GetMapping(value = "/fireAndEventCount", produces = "application/json;charset=UTF-8")
    @ApiOperation("首页-巡护巡航上报火情/事件总数")
    public DataReturn fireAndEventCount( @RequestParam(value = "districtCode",required = true) String districtCode) {
        return DataReturn.ok(fireAndEventHomeService.selectFireAndEventCountByDistrictCode(districtCode));
    }
}
